﻿// ***********************************************************************
// Assembly         : STX.Domain
// Author           : seven.x
// Created          : 01-03-2014
//
// Last Modified By : seven.x
// Last Modified On : 01-18-2014
// ***********************************************************************
// <copyright file="BizActivityItem.cs" company="驰创数码">
//     Copyright (c) 驰创数码. All rights reserved.
// </copyright>
// <summary></summary>
// ***********************************************************************
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;

namespace STX.Domain
{
    /// <summary>
    /// Class 活动所需物料明细.
    /// </summary>
    public class BizActivityItem:BaseEntity
    {
        /// <summary>
        /// 活动ID
        /// </summary>
        /// <value>The activity unique identifier.</value>
        public int ActivityId { get; set; }

        /// <summary>
        /// Gets or sets the quote price template unique identifier.
        /// </summary>
        /// <value>The quote price template unique identifier.</value>
        public string TpCode { get; set; }


        /// <summary>
        /// 物料分类ID
        /// </summary>
        /// <value>The material category unique identifier.</value>
        public int MaterialCategoryId { get; set; }

        /// <summary>
        /// Gets or sets the supplier unique identifier.
        /// </summary>
        /// <value>The supplier unique identifier.</value>
        [Obsolete("此属性已经太老了，择日将被移除")]
        public int? SupplierId { get; set; }

        [NotMapped]
        public ICollection<int> SupplierIds { get; set; }

        /// <summary>
        /// Gets or sets the name of the supplier.
        /// </summary>
        /// <value>The name of the supplier.</value>
        public string SupplierName { get; set; }

        /// <summary>
        /// 物料名称
        /// </summary>
        /// <value>The name.</value>
        public string Name { get; set; }


        /// <summary>
        /// 具体要求
        /// </summary>
        /// <value>The information.</value>
        public string Require { get; set; }


        /// <summary>
        /// 单位
        /// </summary>
        /// <value>The unit.</value>
        public string Unit { get; set; }


        /// <summary>
        /// 数量
        /// </summary>
        /// <value>The numb.</value>
        public decimal Numb { get; set; }


        /// <summary>
        /// 业务员报价
        /// </summary>
        /// <value>The quotation price.</value>
        public decimal QuotationPrice { get; set; }


        /// <summary>
        /// 项目成本价
        /// </summary>
        /// <value>The cost price.</value>
        public decimal ProjectCostPrice { get; set; }


        /// <summary>
        /// 财务成本价
        /// </summary>
        /// <value>The finance price.</value>
        public decimal FinanceCostPrice { get; set; }

        public virtual List<BizActivityItemSupplier> BizActivityItemSuppliers { get; set; }

        public ErrorStatusEnum ErrorStatus { get; set; }

        public enum ErrorStatusEnum
        {
            [Field(Name = "--")]   None = 0,

            [Field(Name = "有问题")] Error = 1,

            [Field(Name = "正确")] Correct = 2,
        }

        /// <summary>
        /// 物料形式
        /// </summary>
        /// <value>The material form.</value>
        public MaterialFormEnum MaterialForm { get; set; }

        /// <summary>
        /// Enum MaterialFormEnum
        /// </summary>
        public enum MaterialFormEnum
        {
            

            /// <summary>
            /// The own leasing
            /// </summary>
            [Field(Name = "自有租赁")]
            OwnLeasing = 0,

            /// <summary>
            /// The out leasing
            /// </summary>
            [Field(Name = "外部租赁")]
            OutLeasing = 1,

            /// <summary>
            /// The buy
            /// </summary>
            [Field(Name = "采购")]
            Buy = 2
        }

        [NotMapped]
        public string MaterialFormString
        {
            get
            {
                return ((MaterialFormEnum) MaterialForm).GetFiledName();
            }
        }

        /// <summary>
        /// 物料归属
        /// </summary>
        /// <value>The material belong.</value>
        public MaterialBelongEnum MaterialBelong { get; set; }

        /// <summary>
        /// Enum MaterialBelongEnum
        /// </summary>
        public enum MaterialBelongEnum
        {
            /// <summary>
            /// The party aggregate retake
            /// </summary>
            [Field(Name = "甲方回收")]
            PartyARetake = 0,

            /// <summary>
            /// The company retake
            /// </summary>
            [Field(Name = "公司回收")]
            CompanyRetake = 1,
        }

        [NotMapped]
        public string MaterialBelongString
        {
            get
            {
                return ((MaterialBelongEnum)MaterialBelong).GetFiledName();
            }
        }

        /// <summary>
        /// 物料分类
        /// </summary>
        /// <value>The biz material category.</value>
        public virtual BizMaterialCategory BizMaterialCategory { get; set; }


        /// <summary>
        /// 所属活动
        /// </summary>
        /// <value>The biz activity.</value>
        public virtual BizActivity BizActivity { get; set; }


        /// <summary>
        /// Gets or sets the biz supplier.
        /// </summary>
        /// <value>The biz supplier.</value>
        public virtual BizSupplier BizSupplier { get; set; }

        [NotMapped]
        public string MaterialCategoryName {
            get
            {
                return BizMaterialCategory == null ? string.Empty : BizMaterialCategory.Name;
            }
        }

        /// <summary>
        /// 性质 （活动/非活动）
        /// </summary>
        [NotMapped]
        public int MaterialType
        {
            get
            {
                return BizMaterialCategory == null ? 0 : (int) BizMaterialCategory.Type;
            }
        }
    }
}
